package com.trumeen.immichgallery.di

import android.content.Context
import com.trumeen.immichgallery.network.ImmichService
import com.trumeen.immichgallery.network.RetrofitClient
import com.trumeen.immichgallery.repository.AuthManager
import com.trumeen.immichgallery.repository.NetworkRepository
import com.trumeen.immichgallery.repository.SettingsDataStore
import com.trumeen.immichgallery.repository.dataStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppModule {

    @Provides
    @Singleton
    fun provideImmichService(): ImmichService {
        return RetrofitClient.apiService
    }

    @Provides
    @Singleton
    fun provideAuthManager(@ApplicationContext context: Context): AuthManager {
        return AuthManager(context.dataStore)
    }

    @Provides
    @Singleton
    fun provideSettingsDataStore(@ApplicationContext context: Context): SettingsDataStore {
        return SettingsDataStore(context.dataStore)
    }

    @Provides
    @Singleton
    fun provideNetworkRepository(
        immichService: ImmichService
    ): NetworkRepository {
        return NetworkRepository(immichService)
    }
}